package com.zhen.service;

import com.zhen.dao.GoodsMapper;
import com.zhen.pojo.Goods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

@Service
public class GoodsServiceImpl implements GoodsService{

    @Autowired
    private GoodsMapper goodsMapper;

    public void setGoodsMapper(GoodsMapper goodsMapper) {
        this.goodsMapper = goodsMapper;
    }

    @Override
    public List<Goods> queryAllGoods() {
        return goodsMapper.queryAllGoods();
    }

    @Override
    public List<Goods> queryGoodsByName(String name) {
        return goodsMapper.queryGoodsByName(name);
    }

    @Override
    public int addGoods(String name,int price,String image) {
        Goods goods = new Goods();
        goods.setName(name);
        goods.setPrice(BigDecimal.valueOf(price));
        goods.setImage(image);
        return goodsMapper.addGoods(goods);
    }

    @Override
    public int deleteGoodsById(int id) {
        return goodsMapper.deleteGoodsById(id);
    }
}
